//
//  UITextField+HHAccessory.m
//  HHUIKit
//
//  Created by chun.chen on 2021/9/2.
//

#import "UITextField+HHAccessory.h"
#import <BCFoundation/BCFoundationUtils.h>

@implementation UITextField (HHAccessory)

- (void)hh_setAccessoryView:(void (^_Nullable)(NSInteger menuIndex) )clickAction {
    
    HHAccessoryView *accessoryView = [[HHAccessoryView alloc] initWithFrame:CGRectMake(0, 0, kBCSCREEN_WIDTH, 44)];
    accessoryView.backgroundColor = [UIColor whiteColor];
    accessoryView.cancelButton.hidden = YES;
    accessoryView.showTopSplit = YES;
    [accessoryView setMenuClickAction:^(HHAccessoryView *_Nonnull view, NSInteger menuIndex) {
        if (clickAction) {
            clickAction(menuIndex);
        }
    }];
    self.inputAccessoryView = accessoryView;
}

@end

@implementation UITextView (HHAccessory)
- (void)hh_setAccessoryView:(void (^_Nullable)(NSInteger menuIndex) )clickAction {
    
    HHAccessoryView *accessoryView = [[HHAccessoryView alloc] initWithFrame:CGRectMake(0, 0, kBCSCREEN_WIDTH, 44)];
    accessoryView.backgroundColor = [UIColor whiteColor];
    accessoryView.cancelButton.hidden = YES;
    [accessoryView setMenuClickAction:^(HHAccessoryView *_Nonnull view, NSInteger menuIndex) {
        if (clickAction) {
            clickAction(menuIndex);
        }
    }];
    self.inputAccessoryView = accessoryView;
}

@end
